package dao

import (
	"frontend-server/db"
	model "frontend-server/model/gv_im"
)

// 消息类型
type MessageType struct {
	Type int `json:"type"`
}

// 创建消息
func CreateGvImMessage(message model.GvImMessage) error {
	db := db.GetImDB()
	err := db.Table("gv_im_message").Create(&message).Error
	return err
}

// 聊天记录查询
func GetGvImMessageRListByRoomID(roomID uint, pageSize, skip int) ([]model.GvImMessage, error) {
	db := db.GetImDB()
	userRooms := []model.GvImMessage{}
	err := db.Table("gv_im_message").Where("room_id = ?", roomID).Offset(skip).Limit(pageSize).Order("created_at desc").Find(&userRooms).Error
	return userRooms, err
}
